<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8"/>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}">
    <link rel="stylesheet" th:href="@{/css/bootstrap.min.css}">
    <link rel="stylesheet" th:href="@{/semantic/semantic.min.css}"/>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome/css/font-awesome.min.css">
</head>
<body>
<div class="layui-form layui-form-pane" style="padding: 20px">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label"><i class="ui violet user outline icon"></i>员工ID</label>
            <div class="layui-input-block">
                <input type="number" lay-verify="required" name="staffId" class="layui-input">
                <input type="hidden" name="type" th:value="0">
                <input type="hidden" name="projectId" th:value="${projectId}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label"><i class="ui blue font icon"></i>项目类型</label>
            <div class="layui-input-inline">
                <select name="staffType" lay-verify="required">
                    <option value="">请选择工作</option>
                    <option value="1">模型</option>
                    <option value="2">渲染</option>
                    <option value="3">后期</option>
                </select>
            </div>

        </div>
        <div class="layui-inline" style="padding-left: -10px">
            <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="staff">分配</button>
        </div>
    </div>
</div>
<div class="layui-form layui-form-pane" style="padding-left: 20px">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label"><i class="ui violet user outline icon"></i>主管ID</label>
            <div class="layui-input-block">
                <input type="number" name="staffId" class="layui-input">
                <input type="hidden" name="type" th:value="1">
                <input type="hidden" name="projectId" th:value="${projectId}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label"><i class="ui blue font icon"></i>管理类型</label>
            <div class="layui-input-inline">
                <select name="staffType" lay-verify="required">
                    <option value="">请选择工作</option>
                    <option value="1">模型管理</option>
                    <option value="2">渲染管理</option>
                    <option value="3">后期管理</option>
                </select>
            </div>
        </div>
        <div class="layui-inline" style="padding-left: -10px">
            <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="leader">分配</button>
        </div>
    </div>
</div>
<script type="text/javascript" th:src="@{/js/jquery-3.4.1.min.js}"></script>
<script type="text/javascript" th:src="@{/semantic/semantic.min.js}"></script>
<script type="text/javascript" th:src="@{/layui/layui.js}"></script>
<script type="text/javascript" th:src="@{/js/upload.js}"></script>
<script th:inline="javascript">
    layui.use(['form', 'layedit', 'laydate'], function () {
        const form = layui.form
            , layer = layui.layer
            , laydate = layui.laydate;
        form.render('select');
        function set(data){
            $.ajax({
                url: "/project/staff/set",
                method: "post",
                contentType: "application/json;charset=utf-8",
                data:JSON.stringify(data.field),
                dataType: "json",
                success: function (res) {
                    if (res.msg === "FAIL"){
                        layer.alert(res.result, {
                            icon: 2,
                            skin: 'layer-ext-moon'
                        })
                    }else {
                        layer.alert('分配成功', {
                            icon: 1,
                            skin: 'layer-ext-moon'
                        })
                    }
                }
            })
        }
        form.on('submit(staff)', function (data) {
            set(data)
        })
        form.on('submit(leader)', function (data) {
            set(data)
        });
    });
</script>